package com.geeklan.base.toast;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.Toast;

import com.smart.base.databinding.ToastMessageLayoutBinding;


public class MyToast extends Toast {
    /**
     * Construct an empty Toast object.  You must call {@link #setView} before you
     * can call {@link #show}.
     *
     * @param context The context to use.  Usually your {@link Application}
     *                or {@link Activity} object.
     */
    public MyToast(Context context, String message) {
        super(context);
        ToastMessageLayoutBinding toastMessageLayoutBinding = ToastMessageLayoutBinding.inflate(LayoutInflater.from(context));
        toastMessageLayoutBinding.tvMessage.setText(message);
        setGravity(Gravity.CENTER_VERTICAL, 0, 0);
        setDuration(Toast.LENGTH_SHORT);
        setView(toastMessageLayoutBinding.getRoot());
    }

    public MyToast(Context context, String message,int duration) {
        super(context);
        ToastMessageLayoutBinding toastMessageLayoutBinding = ToastMessageLayoutBinding.inflate(LayoutInflater.from(context));
        toastMessageLayoutBinding.tvMessage.setText(message);
        setGravity(Gravity.CENTER_VERTICAL, 0, 0);
        setDuration(duration);
        setView(toastMessageLayoutBinding.getRoot());
    }
}
